using UnityEngine;

public class FPS : MonoBehaviour
{
	public UILabel label;

	public float updateInterval = 0.5f;

	private float accum;

	private int frames;

	private float timeleft;

	private void Start()
	{
		if (label == null)
		{
			label = GetComponent<UILabel>();
		}
		timeleft = updateInterval;
	}

	private void Update()
	{
		timeleft -= Time.deltaTime;
		accum += Time.timeScale / Time.deltaTime;
		frames++;
		if ((double)timeleft <= 0.0)
		{
			float num = accum / (float)frames;
			string text = string.Format("{0:F2} FPS", num);
			label.text = text;
			timeleft = updateInterval;
			accum = 0f;
			frames = 0;
		}
	}
}
